<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var a = 9;

        function fn() {
            a = 0;
            return function(b) {
                return b + a++;
            }
        }
        var f = fn(); // a = 0
        console.log(f(5)); // 输出 5 a = 1
        console.log(fn()(5)); //输出5 a = 1
        console.log(f(5)) //输出6 a = 2
        console.log(a) // 输出2
    </script>
</body>

</html>